﻿Public Class BorderDef
	' (n) - Margin
	' [n] - Color
	' {n} - Thickness
	Private _color = String.Empty
	Private _thickness = String.Empty
	Private _margin = String.Empty
	Private Sub Reset()
		_color = String.Empty
		_thickness = String.Empty
		_margin = String.Empty
	End Sub
	Public WriteOnly Property Def() As String
		Set(ByVal value As String)
			Call Reset()
			While InStr("[{(", Mid(value, 1, 1)) > 0 AndAlso value <> String.Empty
				Select Case Mid(value, 1, 1)
					Case "["
						value = Mid(value, 2)
						Dim p = InStr(value, "]")
						If p > 0 Then
							_color = String.Format("BorderBrush=""{0}"" ", Mid(value, 1, p - 1))
							value = Mid(value, p)
						End If
					Case "{"
						value = Mid(value, 2)
						Dim p = InStr(value, "}")
						If p > 0 Then
							_thickness = String.Format("BorderThickness=""{0}"" ", Mid(value, 1, p - 1))
							value = Mid(value, p)
						End If
					Case "("
						value = Mid(value, 2)
						Dim p = InStr(value, ")")
						If p > 0 Then
							_margin = String.Format("Margin=""{0}"" ", Replace(Mid(value, 1, p - 1), "/", ","))
							value = Mid(value, p)
						End If
				End Select
				value = Mid(value, 2)
			End While
			If _margin = String.Empty Then
				_margin = String.Format("Margin=""{0}"" ", "0,2")
			End If
			If _color = String.Empty Then
				_color = "BorderBrush=""Black"" "
			End If
			If _thickness = String.Empty Then
				_thickness = "BorderThickness=""1"" "
			End If
		End Set
	End Property
	Public Property Color() As String
		Get
			Return _color
		End Get
		Set(ByVal value As String)
			_color = value
		End Set
	End Property
	Public Property Thickness() As String
		Get
			Return _thickness
		End Get
		Set(ByVal value As String)
			_thickness = value
		End Set
	End Property
	Public Property Margin() As String
		Get
			Return _margin
		End Get
		Set(ByVal value As String)
			_margin = value
		End Set
	End Property
End Class
